#include "user_extern.h"

//0-select; 1-act
static uint8_t page = 0;
static uint8_t subidx = 0;
static uint8_t power = 0;
os_timer_t digimon_train;
static void digimon_train_cb(void *args)
{
    power += 10;
    if (power > 100)
    {
        power = 10;
    }
}
/****************************************
 *  名称： system_digimon_show_time
 *  功能： digimon 显示时间界面
 *  参数： 
 *  返回值：DIGI_VOID
 ****************************************/
uint8_t digi03_train_display(void)
{
    if (page == 0)
    {
        power = 0;
        Dsystem.ui_frame_time = 100;
        system_digimon_training_select(subidx);
    }
    else if (page == 1)
    {
        Dsystem.ui_frame_time = 50;
        if (!system_digimon_training_act(subidx, power))
        {
            subidx = 0;
            page = 0;
        }
    }
    else if (page == 2)
    {
        system_digimon_training_classic_movic(power);
        page = 0;
    }

    return WINDOWS_STATUS_DIS_ONLY;
}

uint8_t digi03_train_btn_select(void *arg)
{
    if (page == 0)
    {
        subidx++;
        if (subidx > 2)
        {
            subidx = 0;
        }
    }

    return 0;
}

uint8_t digi03_train_btn_enter(void *arg)
{
    if (page == 0)
    {
        if (subidx == 0)
        {
            os_timer_disarm(&digimon_train);
            os_timer_setfn(&digimon_train, (os_timer_func_t *)digimon_train_cb, 0);
            os_timer_arm(&digimon_train, 100, 1);
        }
    }
    else if (page == 1)
    {
        if (subidx == 0)
        {
            /* 安下确定键得到结果，停止定时器 */
            os_timer_disarm(&digimon_train);
        }
    }
    page++;
    return WINDOWS_STATUS_DIS_ONLY;
}

uint8_t digi03_train_btn_exit(void *arg)
{
    if (page == 0)
    {
        Dsystem.windows_cur_id = WIN_UI_DIGIMON;
    }
    else
    {

        page = 0;
    }
    os_timer_disarm(&digimon_train);
    return WINDOWS_STATUS_DIS_ONLY;
}
